package org.springblade.modules.repair.entity;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.HashMap;
import java.util.List;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.repair.vo.part.PartWordUrlVo;

/**
    * 故障工单明细
    */
@Data
@EqualsAndHashCode(callSuper=true)
@TableName(value = "blade_maintain_parts_work",autoResultMap = true)
public class MaintainPartsWork extends TenantEntity {

	private static final long serialVersionUID = -4011761447320358520L;
	/**
     * 任务id
     */
    @TableField(value = "plan_id")
    private Long planId;

    /**
     * 部件id集合
     */
    @TableField(value = "parts_id")
    private String partsId;

    /**
     * 部件名称集合
     */
    @TableField(value = "parts_name")
    private String partsName;

	/**
	 * 部件关联的类目id
	 */
	@TableField(value = "category_id")
	private Long categoryId;

	/**
	 * 申请时，部件关联的skuId
	 */
	@TableField(value = "sku_id")
	private Long skuId;
	/**
	 * 申请时，关联sku配件信息
	 */
	@TableField(value = "sku_parts_info",typeHandler = JacksonTypeHandler.class)
	private JSONObject skuPartsInfo;

	/**
	 * 审批后，部件关联的skuId
	 */
	@TableField(value = "finally_sku_id")
	private Long finallySkuId;
	/**
	 * 审批后，关联sku配件信息
	 */
	@TableField(value = "finally_sku_parts_info",typeHandler = JacksonTypeHandler.class)
	private JSONObject finallySkuPartsInfo;

	/**
	 * 层站结构id集合
	 */
	@TableField(value = "floor_stand_ids")
	private String floorStandIds;

	/**
	 * 层站结构名称集合
	 */
	@TableField(value = "floor_stand_names")
	private String floorStandNames;

    /**
     * 部件名称
     */
    @TableField(value = "`name`")
    private String name;

	/**
	 * 电梯状态： 1-正常,2-停梯
	 */
	@TableField(value = "elevator_stop")
	private Integer elevatorStop;

    /**
     * 部件型号
     */
    @TableField(value = "parts_model")
    private String partsModel;

    /**
     * 部件数量
     */
    @TableField(value = "num")
    private Integer num;

    /**
     * 描述
     */
    @TableField(value = "`desc`")
    private String desc;

    /**
     * 描述图片和视频
     */
    @TableField(value = "other_url",typeHandler = JacksonTypeHandler.class)
    private List<HashMap<String,String>> otherUrl;

    /**
     * 报价分组id
     */
    @TableField(value = "group_id")
    private Long groupId;

	/**
	 * 配件信息
	 */
	private String partsInfo;

	/**
	 * 其它配件信息
	 */
	private String otherInfo;

	/**
	 * word的附件URL
	 */
	@TableField(value = "ext_word_url",typeHandler = JacksonTypeHandler.class)
	private List<HashMap<String, String>> extWordUrl;

	@ApiModelProperty("维修记录配件id")
	private Long malPartId;

	@ApiModelProperty("维修详情id")
	private Long malWorksId;

	@ApiModelProperty("维修记录配件id")
	@TableField(exist = false)
	private Integer planStatus;

	@ApiModelProperty("审核图片")
	@TableField(value = "imgs",typeHandler = JacksonTypeHandler.class)
	private List<PartWordUrlVo> imgs;

	/**
	 * 2025-06 新增单位名称
	 */
	@ApiModelProperty("单位名称")
	@TableField(value = "unit_name_value")
	private String unitNameValue;

	@TableField(exist = false)
	private List<MaintainPartsWorkSku> skuList;

	public void setPartsName(String partsName) {
		if(Func.isNotEmpty(partsName)){
			this.partsName = partsName.replace("&amp;&amp;",">");
		}
	}

	public void setFloorStandNames(String floorStandNames) {
		if(Func.isNotEmpty(floorStandNames)){
			this.floorStandNames = floorStandNames.replace("&amp;&amp;",">");
		}
	}
}
